<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output method='xml'
	indent="yes"
	omit-xml-declaration="yes"
	doctype-public = "-//W3C//DTD XHTML 1.0 Strict//EN"
	doctype-system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
	/>


<!-- includes -->
<xsl:include href="admin_template.xsl"/>

<!-- parameters -->
<xsl:param name="_user_level"/>

<xsl:param name="realname"/>
<xsl:param name="lastlogin"/>

<!-- form data + error handling -->
<xsl:param name="_id"/>

<xsl:param name="_name"/>
<xsl:param name="_name_empty_error"/>
<xsl:param name="_comment"/>
<xsl:param name="_comment_empty_error"/>
<xsl:param name="_email"/>
<xsl:param name="_url"/>
<xsl:param name="_imagecode"/>
<xsl:param name="_imagecode_empty_error"/>
<xsl:param name="_imagecode_valid_error"/>
<xsl:param name="_image"/>

<xsl:param name="_comment_uploaded"/>


<xsl:template match="/">
<html>

<!-- html head -->
<xsl:call-template name="admin_head">
	<xsl:with-param name="_title">Comments</xsl:with-param>
</xsl:call-template>


<body>
	<!-- content -->
<div id="admin_content_div">

<!-- display form -->
<xsl:if test="not($_comment_uploaded)">

	<div id="admin_form_div">

		<!-- error list -->
		<xsl:if test="$_name_empty_error"><li>Please fill the name field</li></xsl:if>
		<xsl:if test="$_comment_empty_error"><li>Please fill the comment field</li></xsl:if>
		<xsl:if test="$_imagecode_empty_error"><li>Please fill the image code field</li></xsl:if>
		<xsl:if test="$_imagecode_valid_error"><li>Invalid image code</li></xsl:if>

		<form method="post" enctype="multipart/form-data">
										<xsl:attribute name="action">index.php?op=comment&amp;id=<xsl:value-of select="$_id"/></xsl:attribute>

										<!-- name field -->
										<p id="admin_form_p">
											<label id="admin_form_label" for="real_name">Name:</label>
											<input type="text" name="name" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_name"/>
												</xsl:attribute>
												<xsl:if test="$_name_empty_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
											</input>
										</p>

										<!-- comment field -->
										<p id="admin_form_p">
											<label id="admin_form_label" for="desc">Comment:</label>
											<textarea name="comment" rows="4" cols="30" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_comment"/>
												</xsl:attribute>
												<xsl:if test="$_comment_empty_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
											</textarea>
										</p>

										<!-- email field -->
										<p id="admin_form_p">
											<label id="admin_form_label" for="desc">Email:</label>
											<input type="text" name="email" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_email"/>
												</xsl:attribute>


											</input>
										</p>

										<!-- url field -->
										<p id="admin_form_p">
											<label id="admin_form_label" for="desc">Url:</label>
											<input type="text" name="url" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_url"/>
												</xsl:attribute>
											</input>
										</p>
										<!-- image -->
										<div id="image code">
											<img id="img_code">
												<xsl:attribute name="src"><xsl:value-of select="$_image"/></xsl:attribute>
											</img>
											<input type="hidden" name="image">
												<xsl:attribute name="value">
													<xsl:value-of select="$_image"/>
												</xsl:attribute>
											</input>
										</div>
										<!-- image code field -->
										<p id="admin_form_p">
											<label id="admin_form_label" for="desc">Imagecode:</label>
											<input type="text" name="imagecode" id="admin_form_textfield">
												<xsl:attribute name="value">
													<xsl:value-of select="$_imagecode"/>
												</xsl:attribute>
												<xsl:if test="$_imagecode_empty_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
												<xsl:if test="$_imagecode_valid_error">
													<xsl:attribute name="id">admin_form_textfield_error</xsl:attribute>
												</xsl:if>
											</input>
										</p>


										<!-- buttons -->
										<p id="admin_buttons_p">
											<input type="hidden" name="form_posted" value="posted"/>
											<input type="submit" value="Send" id="admin_form_button"/>
										</p>

		</form>
	</div>
</xsl:if>

<xsl:if test="$_comment_uploaded">
	<h3>Your comment is awaiting moderation.</h3>
	<strong>Name: </strong><xsl:value-of select="$_name"/><br/>
	<strong>Comment: </strong><xsl:value-of select="$_comment"/><br/>
	<a>
		<xsl:attribute name="href">index.php?op=blog&amp;id=<xsl:value-of select="$_id"/></xsl:attribute>Back
	</a>
</xsl:if>
</div>

</body>
</html>
</xsl:template>

</xsl:stylesheet>
